
#ifndef GLOBAL_H
#define GLOBAL_H

#include "JsonParse.h"
#include "SimpleMap.h"
#include "blefunc.h"
#include "List.h"


const  static int APP_MODE_HIGH = 1;
const static int APP_MODE_SAVE=2;  // 省电模式
const static int APP_MODE_SMART=3; // 智能模式

const static int CODE_PUMP_ON=1008; 
const static int CODE_PUMP_OFF=1009; 
const static int CODE_POWER_OFF=1010; 
const static int CODE_UPDATE_CONFIG=1011; 


const  String  BUCKET_WATER_V1 = "bucket_water_v1";
const  String  BUCKET_WATER_V2 = "bucket_water_v2";


typedef void (*FuncCallBack)(String);

typedef void (*FuncCallBack1)(void*);


class B
{
public:
  char id[20];
  unsigned long time;

public:
  B(/* args */)
  {
  }
  ~B()
  {
  }
};
class FuncCallBackStruct
{
public:
  FuncCallBack callback;
  String key;
  long count = 0;// 用户计数，调用一次加一

  void plusCount()
  {
    count++;
  }

  void resetCount()
  {
    count = 0;
  }
  /* data */
public:
  FuncCallBackStruct(/* args */)
  {
  }
  ~FuncCallBackStruct()
  {
  }
};



class FuncCallBackStruct1
{
public:
  FuncCallBack1 callback;
  String key;
  long count = 0;// 用户计数，调用一次加一

  void plusCount()
  {
    count++;
  }

  void resetCount()
  {
    count = 0;
  }
  /* data */
public:
  FuncCallBackStruct1(/* args */)
  {
  }
  ~FuncCallBackStruct1()
  {
  }
};


class RemoteDataBean{
private:
  long timestamp;
  float humiValue;
  float vcc;

public:

  RemoteDataBean(){
    
  }

  RemoteDataBean(float humiValue,float vcc,long timestamp){
    this->humiValue = humiValue;
    this->vcc = vcc;
    this->timestamp = timestamp;
  }


  void setTimeStamp(long ts){
    this->timestamp = ts;
  }

  long getTimeStamp(){
    return timestamp;
  }

  float getVcc(){
    return vcc;
  }

  void setVcc(float v){
    this->vcc = v;
  }


  float getHumiValue(){
    return humiValue;
  }

  void setHumiValue(float value){
    this->humiValue = value;
  }
  
};

class RemoteBleData
{
  private:
    List<RemoteDataBean> remoteDataList;

    String remoteDataListStr;


  public :
     String getRemoteDataListStr(){
      return remoteDataListStr;
     }
      void setRemoteDataListStr(String data){
        this->remoteDataListStr = data;
      }

    List<RemoteDataBean> getRemoteDataList(){
      return remoteDataList;
    }

    void setRemoteDataList(  List<RemoteDataBean> list){
      this->remoteDataList = list;
    }

  RemoteBleData(/* args */){
     
  };
  ~RemoteBleData(){

  };
};

 


static const String APP_INIT = "app_init";

void setGlobalTimerAction(TimerAction *ta);
TimerAction *getGlobalTimerAction();
void deleteGlobalTimerAction();



void setGlobalLocalConfig(LocalConfig *ta);
LocalConfig *getGlobalLocalConfig();
void deleteGlobalLocalConfig();

bool addGlobalFuncCallBack(String key, FuncCallBack1 fcb);
void removeGlobalFuncCallBack(String key);
FuncCallBack1 getGlobalFuncCallBack(String key);

bool addGlobalTimerCallBack(String key, FuncCallBack fcb);
void removeGlobalTimerCallBack(String key);
FuncCallBack getGlobalTimerCallBack(String key);


bool addGlobalTimerCallBack1(String key, FuncCallBack1 fcb);
void removeGlobalTimerCallBack1(String key);
FuncCallBack getGlobalTimerCallBack1(String key);


 



SimpleMap<String,RemoteBle*>* getRemoteBleMap();
SimpleMap<String,RemoteBleData*>* getRemoteBleDataMap();





bool isNeedConnectWiFi();
bool isNeedSendActive();
void setNeedConnectWiFi(bool b);
void setNeedSendActive(bool b);

bool isWiFiConnected();
void setWiFiConnected(bool b);

void setGlobalRTCIntervalAciton();

B getB(String id);

int getAppMode();
void setAppMode(int mode);

bool isAllowOfflineRun();

bool isActive();

void setActive(bool b);

void setTimerWakeup(String second);
long getTimerWakeup();
 bool excuteDelay(long delay,FuncCallBack  calback);
  bool excuteDelay(long delay,String id,FuncCallBack  calback);
  void cancelExcuteDelay(String id);

 bool isHasUpgrade();

 bool isAllowUpgrade();

 void setAllowupgrade(bool b);
 void setDeviceType(String deviceTypeVal);
String getDeviceType();

bool isReboot();

void setReboot(bool val);

void setSendPing(bool);

bool isSendPing();
void setSendData(bool);
bool isSendData();

bool isSendDataFailed();
void setSendDataFailed(bool);

bool isSendNotice();

void closePump();

bool isAppReady();

void setAppReady(bool b);

void setGlobalSleepdelayTime(long time);

long getGlobalSleepdelayTime();
  

#endif